<!--
 * @Description: 
 * @version: 
 * @Author: erze
 * @Date: 2021-05-18 19:06:20
 * @LastEditors: erze
 * @LastEditTime: 2021-05-19 08:15:36
-->
<template>
  <div class="z-form">
    <slot></slot>
  </div>
</template>

<script>
export default {
  // 祖孙传参
  provide() {
    return {
      form: this
    };
  },
  props: {
    model: {
      type: Object
    },
    rules: {
      type: Object
    }
  },
  methods: {
    // 多条校验
    validate(callback) {
      // 一个promise组成的数组
      const list = this.$children.map(item => {
        if (item.prop) {
          return item.validate();
        }
      });
      Promise.all(list)
        .then(() => {
          callback(true);
        })
        .catch(() => {
          callback(false);
        });
    }
  }
};
</script>

<style>
</style>